// This file defines unified styles for UI elements such as form fields.

.form-tray {
	display: flex;
	margin: 10px 0;
	
	input {
		margin: 0 5px;
	}
}

input[type="button"] {
	padding: 9px 13px;
	background: var(--form-button-base);
	color: var(--font-primary);
	font-size: 17px;
	border: 0;
	border-radius: 5px;
	cursor: pointer;

	&:hover:not(.disabled) {
		background: var(--form-button-hover);
		color: var(--font-highlight);
	}

	&.disabled {
		cursor: default;
		opacity: 0.5;
		background: var(--form-button-disabled);
	}
}

.context-menu {
	position: fixed;
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	box-shadow: black 0 0 3px 0;
	background: #232323;
	z-index: 5;

	&.low {
		transform: translateY(-100%);
	}

	&.left {
		transform: translateX(-100%);
	}

	&.low.left {
		transform: translate(-100%, -100%);
	}

	&-zone {
		position: absolute;
		left: -20px;
		top: -20px;
		bottom: -20px;
		right: -20px;
		z-index: -1;
	}

	> span {
		padding: 8px;
		border-bottom: 1px solid var(--border);
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;

		&:hover {
			background: #353535;
			cursor: pointer;
		}

		&:last-child {
			border-bottom: 0;
		}
	}
}

.ui-multi-button {
	list-style: none;

	li:first-child {
		border-top-left-radius: 5px;
		border-bottom-left-radius: 5px;
	}

	li:last-child {
		border-top-right-radius: 5px;
		border-bottom-right-radius: 5px;
	}

	li:not(:first-child) {
		margin-left: 1px;
	}

	li {
		background: var(--form-button-base);
		position: relative;
		padding: 10px;
		color: white;
		display: inline-block;
		cursor: pointer;

		&:hover, &.selected {
			background: var(--form-button-hover);
		}
	}
}

.ui-checkbox {
	font-size: 18px;
	display: flex;
	margin: 0 15px;
	align-items: center;
	
	input[type="checkbox"] {
		width: 18px;
		height: 18px;
		margin-right: 5px;
	}
}

.ui-menu-button {
	display: inline-block;
	position: relative;

	input[type="button"] {
		padding-right: 40px;
		padding-left: 13px;
		position: relative;
		z-index: 2;
		height: 100%;
	}

	.menu {
		list-style: none;
		position: absolute;
		background: var(--form-button-menu);
		width: 100%;
		z-index: 1;

		li {
			padding: 8px 10px;
			background: var(--form-button-menu);
			cursor: pointer;

			&:hover {
				background: var(--form-button-menu-hover);
			}
		}
	}

	&:not(.upward) .menu {
		top: 85%;
		padding-top: 5%;

		&, li:last-of-type {
			border-bottom-right-radius: 5px;
			border-bottom-left-radius: 5px;
		}
	}

	&.upward .menu {
		bottom: 85%;
		padding-bottom: 5%;

		&, li:first-of-type {
			border-top-left-radius: 5px;
			border-top-right-radius: 5px;
		}
	}

	&:not(.disabled) {
		.arrow:hover {
			background-color: var(--form-button-hover);
			cursor: pointer;
		}

		&.dropdown:hover, &.open {
			cursor: pointer;

			input[type="button"], .arrow {
				background-color: var(--form-button-hover);
			}
		}
	}

	.arrow {
		z-index: 3;
		position: absolute;
		right: 0;
		top: 0;
		bottom: 0;
		width: 29px;
		display: flex;
		align-items: center;
		justify-content: center;
		border-top-right-radius: 5px;
		border-bottom-right-radius: 5px;
		background-image: url(./fa-icons/caret-down.svg);
		background-repeat: no-repeat;
		background-position: center;
		background-size: 10px;
		border-left: 1px solid #ffffff52;
	}
}

textarea {
	border-radius: 5px;
	resize: none;
	box-shadow: var(--form-field-shadow);
	background: var(--background-trans);
	color: white;
	padding: 10px;
	font-family: 'Selawik', sans-serif;
	font-size: 15px;
}

input[type="text"], input[type="number"] {
	padding: 10px;
	background: var(--background-dark);
	color: var(--font-primary);
	border: 1px solid var(--border);
	margin: 10px;
	border-radius: 5px;
	width: 300px;

	&.long {
		width: 600px;
	}

	&:focus, &:hover {
		color: var(--font-highlight);
	}
}

input[type="number"] {
	width: 50px;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
	display: none;
}

.ui-checkboxlist {
	.item {
		display: flex;
		flex-direction: row;
		align-items: center;

		span {
			display: inline;
			margin: 0 0 1px 5px;
		}
	}
}

.ui-listbox {
	.item:hover {
		background: var(--font-alt) !important;
	}
}

.ui-listbox, .ui-checkboxlist, .ui-datatable {
	background: var(--background);
	position: relative;
	border: 1px solid var(--border);
	box-shadow: black 0 0 3px 0px;
	overflow: hidden;

	.item {
		padding: 2px 8px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		background: var(--background-dark);
		cursor: pointer;
		box-sizing: border-box;

		// If you edit the height here, make sure to edit the identical
		// hard-coded value used in the listbox/checkboxlist components.
		height: 26px;

		&:nth-child(even) {
			background: var(--background-alt);
		}

		&.selected {
			background: var(--font-alt);
		}
	}

	.scroller {
		position: absolute;
		right: 3px;
		width: 8px;
		height: 45px;
		opacity: 0.7;
		cursor: pointer;

		> div {
			position: absolute;
			top: 3px;
			bottom: 3px;
			right: 0;
			left: 0;
			background: var(--border);
			border: 1px solid var(--border);
			border-radius: 5px;
		}

		&:hover, &.using {
			> div {
				background: var(--font-highlight);
			}
		}
	}
}

.ui-datatable{
	width: 100%;
	height: 100%;

	table {
		width: 100%;
		height: 100%;
		background: var(--background-dark);
		padding: 0px;

		&:nth-child(even) {
			background: var(--background-alt);
		}
		
		tr{
			background: var(--background-dark);
			box-sizing: border-box;
			min-height: 32px;
			max-height: 32px;
			height: 32px;

			&:nth-child(even) {
				background: var(--background-alt);
			}

			th{
				border: 1px solid var(--border);
				padding: 10px;
			}
			
			td{
				padding: 5px;
			}
		}
	}

	.scroller {
		margin-top: 46px;
	}
}

.ui-slider {
	position: relative;
	height: 20px;
	margin: 4px 0;
	border: 1px solid var(--border);
	background: var(--background-dark);
	box-shadow: black 0 0 1px;
	
	.fill {
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		z-index: 0;
		background: var(--font-alt);
	}

	.handle {
		position: absolute;
		width: 10px;
		height: 28px;
		left: 50%;
		top: 50%;
		transform: translateY(-50%);
		box-shadow: black 0 0 8px;
		background: var(--border);
		cursor: pointer;
		z-index: 1;

		&:hover {
			background: var(--font-alt);
		}
	}
}

.ui-model-viewer {
	width: 100%;
	height: 100%;
	overflow: hidden;

	canvas {
		display: block;
	}
}

.ui-map-viewer {
	border: 1px solid var(--border);
	background-size: 30px 30px;
	background-position: 0 0, 15px 15px;
	background-color: var(--trans-check-b);
	box-shadow: black 0 0 3px 0;
	background-image: linear-gradient(45deg, var(--trans-check-a) 25%, transparent 25%, transparent 75%, var(--trans-check-a) 75%, var(--trans-check-a)),
	linear-gradient(45deg, var(--trans-check-a) 25%, transparent 25%, transparent 75%, var(--trans-check-a) 75%, var(--trans-check-a));
	margin: 20px 20px 0 10px;
	grid-row: 1;
	grid-column: 2;
	overflow: hidden;
	position: relative;

	canvas {
		display: block;
		width: 100%;
		height: 100%;
	}

	div {
		position: absolute;
		text-shadow: black 0 0 6px;
	}

	.hover-info {
		bottom: 3px;
		left: 3px;
	}

	.info {
		top: 6px;
		left: 0;
		right: 0;
		display: flex;
		justify-content: center;
		white-space: nowrap;
		flex-wrap: wrap;

		span {
			margin: 0 10px;
		}
	}
}

.ui-combobox {
	position: relative;

	ul {
		list-style: none;
		position: absolute;
		top: 100%;
		border: 1px solid var(--border);
		box-shadow: black 0 0 3px 0;
		background: #232323;
		z-index: 5;

		li {
			border-bottom: 1px solid var(--border);
			padding: 10px 15px;

			&:hover {
				background: #353535;
				cursor: pointer;
			}
		}
	}
}